#include "gnurilla.h"

GtkActionGroup *gnurilla_toolbar_action_group (GnurillaData *gd)
{
	GtkActionGroup *toolbar_action_group;
	
	static GtkActionEntry toolbar_entries[] = {
		{"New", GTK_STOCK_NEW, NULL, NULL, "Crea un nuovo file (Ctrl+N)", G_CALLBACK(gnurilla_add_notebook_page) },
		{"Open", GTK_STOCK_OPEN, NULL, NULL, "Apri un file (Ctrl+O)", NULL },
		{"Save", GTK_STOCK_SAVE, NULL, NULL, "Salva un file modificato (Ctrl+S)", NULL },
		{"SaveAs", GTK_STOCK_SAVE_AS, NULL, NULL, "Salva in un file (Ctrl+Shift+S)", NULL },
		
		{"CloseTab", GTK_STOCK_CLOSE, NULL, NULL, "Chiudi (Ctrl+W)", NULL },
		{"PrevTab", GTK_STOCK_GO_BACK, NULL, NULL, "Precedente (Shift+F6)", NULL },
		{"NextTab", GTK_STOCK_GO_FORWARD, NULL, NULL, "Successivo (F6)", NULL },
		
		{"Cut", GTK_STOCK_CUT, NULL, NULL, "Taglia (Ctrl+X)", NULL },
		{"Copy", GTK_STOCK_COPY, NULL, NULL, "Copia (Ctrl+C)", NULL },
		{"Paste", GTK_STOCK_PASTE, NULL, NULL, "Incolla (Ctrl+V)", NULL },
		
		{"Find", GTK_STOCK_FIND, NULL, NULL, "Trova e Rimpiazza... (Ctrl+F)", NULL },
		
		{"Preferences", GTK_STOCK_PREFERENCES, NULL, NULL, "Modifica le preferenze... (Alt+P)", NULL },
		{"Quit", GTK_STOCK_QUIT, NULL, NULL, "Esci da Gnurilla (Ctrl+Q)", G_CALLBACK(gnurilla_cb_delete_event) },
	};
	
	static guint n_entries = G_N_ELEMENTS (toolbar_entries);
	
	toolbar_action_group = gtk_action_group_new ("AppWindowActions");
      	gtk_action_group_add_actions (toolbar_action_group, toolbar_entries, n_entries, gd);
	
	return toolbar_action_group;
};

GtkWidget *gnurilla_create_toolbar (GnurillaData *gd, char *filename)
{
	GtkWidget *toolbar;
	GtkUIManager *merge;
	GtkActionGroup *toolbar_action_group;
	GError *error = NULL;
	
	toolbar_action_group = gnurilla_toolbar_action_group(gd);
	
	merge = gtk_ui_manager_new();
	gtk_ui_manager_insert_action_group(merge, toolbar_action_group, 0);
	gtk_ui_manager_add_ui_from_file(merge, filename, &error);
	
	toolbar = gtk_ui_manager_get_widget (merge, "/Toolbar");
	
	return toolbar;
};
